# 递归


# 阶乘 n!=n*(n-1)*...*1
def fact(n):
    res = n
    for i in range(1, n):
        res *= i
    return res


print(fact(10))  # 3628800


# 阶乘的递归写法
def fact_recursion(n):
    if n == 0 or n == 1:
        return 1
    return n * fact_recursion(n - 1)


print(fact_recursion(10))  # 3628800


# 幂乘
def power(x, n):
    if n == 0:
        return 1
    else:
        return x * power(x, n - 1)


print(power(10, 4))  # 10000

# 函数式编程
l1 = list(map(str, range(10)))  # 与[str(i) for i in range(10)]等价
l2 = [str(i) for i in range(10)]  # 推荐使用列表推导式
print(l1, l2)  # ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']

#
